<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>

</head>

<body>
    <script>
        /**
         * 请求拦截器一般用于向服务器传递一些每次请求都要传输数据，这些数据一般是在请求头中进行携带的
         * 
         * token：令牌  headers
         * 
         */

        // axios.get('/computers', {headers:{token:'xxxx'}})
        // axios.post('/computers', {name:'yyy'}, {headers:{token:'xxxx'}})

        axios.interceptors.request.use(config => {
            config.headers = {
                token:'xxx',
                x:12,
                y:200
            }
            return config;
        }, error => {
            // Do something with request error
            return Promise.reject(error);
        });

        axios.get('http://localhost:3000/computers').then(value=>{
            console.log(value);
        })
    </script>
</body>

</html>